﻿using Abp.Application.Services;
using Abp.AspNetCore.Mvc.Authorization;
using AbpZeroTemplate.Authorization;
using AbpZeroTemplate.Configuration.Tenants;
using AbpZeroTemplate.Configuration.Tenants.Dto;
using AbpZeroTemplate.Web.Controllers;
using AbpZeroTemplate.Web.Swagger;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace AbpZeroTemplate.Api.Admin.Controllers
{
    /// <summary>租户配置
    /// </summary>
    [Area("Admin")]
    [Route("Admin/TenantSettings/[action]")]
    [ApiName("Admin")]
    [RemoteService]
    [AbpMvcAuthorize(AppPermissions.Pages_Administration_Tenant_Settings)]
    public class TenantSettingsController : AbpZeroTemplateControllerBase
    {
        private readonly ITenantSettingsAppService _tenantSettingsAppService;
        /// <summary>
        /// </summary>
        public TenantSettingsController(ITenantSettingsAppService tenantSettingsAppService)
        {
            _tenantSettingsAppService = tenantSettingsAppService;
        }

        /// <summary>获取全部配置
        /// </summary>
        [HttpGet]
        public async Task<TenantSettingsEditDto> GetAllSettings()
        {
            return await _tenantSettingsAppService.GetAllSettings();
        }

        /// <summary>更新全部的配置
        /// </summary>
        [HttpPut]
        public async Task UpdateAllSettings([FromBody]TenantSettingsEditDto input)
        {
            await _tenantSettingsAppService.UpdateAllSettings(input);
        }

        [HttpPost]
        public async Task ClearLogo()
        {
            await _tenantSettingsAppService.ClearLogo();
        }

        [HttpPost]
        public async Task ClearCustomCss()
        {
            await _tenantSettingsAppService.ClearCustomCss();
        }
    }
}
